feat(react): add createMediaComponent - #2604
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d56298a to
84cab08
Compare
@videojs/cdn
@videojs/core
@videojs/element
@videojs/html
@videojs/media
@videojs/react
@videojs/spf
@videojs/store
@videojs/utils
@videojs/cloudflare-video
@videojs/dash-video
@videojs/hlsjs-video
@videojs/mux-audio
@videojs/mux-video
@videojs/native-hls-video
@videojs/shaka-video
@videojs/spotify-audio
@videojs/tiktok-video
@videojs/twitch-video
@videojs/vimeo-video
@videojs/wistia-video
@videojs/youtube-video
@videojs/google-cast
@videojs/mux-data
commit: |
📦 Bundle Size Report🎨 @videojs/html — 30 small size changes
Presets (7)
Media (18)
Players (5)
Skins (29)
UI Components (62)
⚛️ @videojs/react — 24 small size changes
Presets (7)
Media (22)
Extensions (2)
Players (5)
Skins (18)
UI Components (39)
🧩 @videojs/core — no changesEntries (76)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (13)
📦 @videojs/cdn — no changes📦 @videojs/cloudflare-video — no changes📦 @videojs/dash-video — no changes📦 @videojs/google-cast — no changes📦 @videojs/hlsjs-video — no changes📦 @videojs/media — no changesEntries (3)
📦 @videojs/mux — no changes📦 @videojs/mux-audio — no changesEntries (2)
📦 @videojs/mux-data — no changes📦 @videojs/mux-video — no changesEntries (2)
📦 @videojs/native-hls-video — no changes📦 @videojs/shaka-video — no changes📦 @videojs/spf — no changesEntries (7)
📦 @videojs/spotify-audio — no changes📦 @videojs/tiktok-video — no changes📦 @videojs/twitch-video — no changes📦 @videojs/vimeo-video — no changes📦 @videojs/wistia-video — no changesEntries (2)
📦 @videojs/youtube-video — no changesℹ️ How to interpretEach entry is independently bundled, minified, and brotli-compressed. Initial size includes its static import graph; lazy dynamic chunks are reported separately. Entries are not additive because their dependency graphs overlap. Preset rows represent realistic combined bundles. Changes of 300 B or less across initial, lazy, and total size are collapsed, not discarded. Run |
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
84cab08 to
7c1d2e6
Compare
7c1d2e6 to
e155a0c
Compare
e155a0c to
46f504b
Compare
46f504b to
fa437f8
Compare
fa437f8 to
3601865
Compare
3601865 to
3e68162
Compare
3e68162 to
b81d177
Compare
657b514 to
30e54dc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 30e54dc. Configure here.
30e54dc to
4ff3522
Compare
4ff3522 to
06d6e5d
Compare
06d6e5d to
c3cff2f
Compare
✅ Deploy Preview for vjs-registry canceled.
|
✅ Deploy Preview for vjs-registry ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
c3cff2f to
890a13a
Compare
890a13a to
9c3e27b
Compare
9c3e27b to
5e8a81d
Compare
5e8a81d to
3065f9b
Compare
3065f9b to
75c3a60
Compare
`createMediaComponent(tag, Adapter, options?)` builds a component that renders a native `<video>` or `<audio>`, drives it through one adapter instance, syncs the adapter's props from React props against `Adapter.defaultProps`, forwards everything else (and the ref) to the element, and registers with the Player. The six built-in components that followed that exact shape now use it. The media reference builder reads the target and defaults straight from the factory call, so those components keep their generated React prop tables. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Inferring the element from `attach()` mistyped the SPF adapters, whose mixins take an `HTMLMediaElement`, as audio, and the hls.js `MuxAudioAdapter` as video. The adapter's static `host` names the element directly. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every adapter's `host` is a literal now, so the non-distributive check for the video union is gone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

What this does
Adds
createMediaComponent, the React façade factory, and builds every React media component with it exceptWistiaVideoandHlsBackgroundVideo.Shape
createMediaComponent(Adapter, render, options?)The render callback receives:
adapterpropschildrenrefinitialPropssrc)Types follow from the adapter alone: the ref and native attributes come from its
attach()target (MediaAdapterTarget), and the adapter props from its staticdefaultProps. No tag parameter, so iframe embeds and the Mux components (with their storyboard child) use the same factory.Also
useAttachMediaaccepts any element target;useAttachIframeis gone.createMediaComponentreference page.Validation
Build, typecheck, lint,
@videojs/reacttests, builder e2e suite, site tests, regenerated media references.🤖 Generated with Claude Code
Note
Medium Risk
Wide refactor across every media adapter and embed URL/mute behavior; public prop types change for several components, though behavior is covered by new tests and existing suites.
Overview
Introduces
createMediaComponent, a shared factory that wires adapter instances into the Player (prop sync viauseSyncProps, attach ref, frozeninitialPropsfor embed URLs) and delegates rendering to a callback.createMediaComponentand related types are exported from@videojs/react.Nearly all built-in React media components (HlsJsVideo, MuxVideo, iframe embeds, etc.) are rewritten to use the factory instead of duplicated
forwardRef+ hook boilerplate;WistiaVideoandHlsBackgroundVideoare unchanged. Component props are nowMediaComponentProps<typeof Adapter>rather than hand-rolled interface merges (notably simplifying Mux variants).useAttachIframeis removed;useAttachMediais generalized to attach any target element (including iframes). The API docs builder detectscreateMediaComponentcalls to infer React target tag and default props; there are unit tests for the factory and an updated reference doc page.Reviewed by Cursor Bugbot for commit 890a13a. Bugbot is set up for automated code reviews on this repo. Configure here.